// pages/xinxi/xinxi.js
const db = wx.cloud.database();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    data:'',
     openid:'',
     cityname:'',
     Gender:'',
     birthday:'',
     phone:''
  },
  bindTextAreaBlur1: function(e) {
    //console.log(e.detail.value)
    this.setData({Gender:e.detail.value})
  },
  bindTextAreaBlur2: function(e) {
    //console.log(e.detail.value)
    this.setData({birthday:e.detail.value})
  },
  bindTextAreaBlur3: function(e) {
    //console.log(e.detail.value)
    this.setData({cityname:e.detail.value})
  },
  bindTextAreaBlur4: function(e) {
    //console.log(e.detail.value)
    this.setData({phone:e.detail.value})
  },
  xiugai:function(){
     db.collection('users').where({
       _openid:this.data.openid
     }).update({
       data:{
        Gender:this.data.Gender,
        birthday:this.data.birthday,
        phone:this.data.phone,
        cityname:this.data.cityname
       },
       success:res=>{
        // console.log(res)
       }
     })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      let openid = options.openid
      db.collection('users').where({
        _openid:openid
      }).get({
        success:res=>{
          console.log(res)
          this.setData({data:res.data})
          
        }
      })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
    onShow(){
      let openid = getApp().globalData.openid;
      let cityname = getApp().globalData.cityname;
      this.setData({openid,cityname})
      // console.log(openid)
      // console.log(cityname)
    },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})